#include<bits/stdc++.h>
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
typedef long long int ll;
using namespace std;

const int N = 100010;

ll n, m;
ll a[N], s[N];

int main()
{
   close();
   cin>>n>>m;
    for (int i = 1; i <= n; i ++ ) cin>>a[i];

    for (int i = 1; i <= n; i ++ ) s[i] = s[i - 1] + a[i]; // 前缀和的初始化

    while (m -- )
    {
        int l, r;
        cin>>l>>r;
        cout<<s[r] - s[l - 1]<<'\n';
    }

    return 0;
}

